import Vue from 'vue';
import Router from 'vue-router';
import {setStore, getStore} from '../config/mUtils';

import welcome from '../components/pages/home/welcome.vue';
import scenario from '../components/pages/home/scenario.vue';
import progress from '../components/pages/home/progress.vue';
import selectMenu from '../components/pages/home/selectMenu.vue';
import selectSex from '../components/pages/home/selectSex.vue';
import record from '../components/pages/home/record.vue';
import home from '../components/pages/home.vue';
import error from '../components/commons/error/error.vue';

const routes = [
    {
        path: '',
        redirect: '/home'
    },
    {
        path: '/error',
        name: 'Error',
        component: error
    },
    {
        path: '/home',
        name: 'Home',
        component: home,
        redirect: '/home/progress',
        children: [
            {
                path: 'welcome',
                component: welcome
            },
            {
                path: 'selectSex',
                component: selectSex
            },
            {
                path: 'selectMenu',
                component: selectMenu
            },
            {
                path: 'progress',
                component: progress
            },
            {
                path: 'scenario',
                component: scenario
            },
            {
                path: 'record',
                component: record
            }
        ]
    }
];


Vue.use(Router);

export const router = new Router({
    routes,
    history: true
});

router.beforeEach((to, from, next) => {
    //判断路径与底部餐单联动
    next();
});



